package TCP;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;

public class TestSocket
{
    public static void main (String[] args)
    {
        try(//创建Socket
            Socket socket = new Socket("127.0.0.1", 8888);
            //创建向服务端发送消息的流对象
            PrintWriter printWriter = new PrintWriter(socket.getOutputStream());)
        {
            printWriter.println("服务端，你好！");
            printWriter.flush();
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
    }
}
